<?php

namespace App\Entity\Sale;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Base\Annotation\Common;
use App\Entity\Shop\ShopProduct;
use App\Repository\Sale\PromotionProductRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource()
 * @ORM\Entity(repositoryClass=PromotionProductRepository::class)
 */
class PromotionProduct
{
    /**
     * @Common(cnName="#",listType="text",editType="text")
     * @Groups({"sale"})
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @Common(cnName="会场",listType="text",editType="entity",width="200")
     * @Groups({"sale"})
     * @ORM\ManyToOne(targetEntity=PromotionCategory::class, inversedBy="products")
     * @ORM\JoinColumn(nullable=false)
     */
    private $category;

    /**
     * @Common(cnName="产品",listType="text",editType="entity",width="")
     * @Groups({"sale"})
     * @ORM\ManyToOne(targetEntity=ShopProduct::class, inversedBy="promotions")
     * @ORM\JoinColumn(nullable=false)
     */
    private $product;

    /**
     * @Common(cnName="活动价",listType="text",editType="text")
     * @Groups({"sale"})
     * @ORM\Column(type="float", nullable=true)
     */
    private $price;

    /**
     * @Common(cnName="折扣",listType="text",editType="text")
     * @Groups({"sale"})
     * @ORM\Column(type="float", nullable=true)
     */
    private $cut;

    /**
     * @Common(cnName="限量",listType="text",editType="text")
     * @Groups({"sale"})
     * @ORM\Column(type="float", nullable=true)
     */
    private $num;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getCategory(): ?PromotionCategory
    {
        return $this->category;
    }

    public function setCategory(?PromotionCategory $category): self
    {
        $this->category = $category;

        return $this;
    }

    public function getProduct(): ?ShopProduct
    {
        return $this->product;
    }

    public function setProduct(?ShopProduct $product): self
    {
        $this->product = $product;

        return $this;
    }

    public function getPrice(): ?float
    {
        return $this->price;
    }

    public function setPrice(?float $price): self
    {
        $this->price = $price;

        return $this;
    }

    public function getCut(): ?float
    {
        return $this->cut;
    }

    public function setCut(?float $cut): self
    {
        $this->cut = $cut;

        return $this;
    }

    public function getNum(): ?float
    {
        return $this->num;
    }

    public function setNum(?float $num): self
    {
        $this->num = $num;

        return $this;
    }
}
